<template>
  <el-dialog
    :close-on-click-modal="clickClose"
    :visible.sync="visible"
    :title="title"
  >
    <slot></slot>
    <div slot="footer">
      <el-button
        type="primary"
        :loading="confirmLoading"
        @click="$emit('confirm')"
        >确定</el-button
      >
      <el-button @click="visible = false">取消</el-button>
    </div>
  </el-dialog>
</template>
<script>
export default {
  name: "MyDialog",
  data() {
    return {
      /**
       * 是否显示
       */
      visible: false,
      /**
       * loading
       */
      confirmLoading: false,
    };
  },
  methods: {
    /**
     * 显示
     */
    show() {
      this.visible = true;
    },
    /**
     * 隐藏
     */
    hide() {
      this.visible = false;
    },
    /**
     * 开始loading
     */
    start() {
      this.confirmLoading = true;
    },
    /**
     * 结束loading
     */
    stop() {
      this.confirmLoading = false;
    },
  },
  props: {
    /**
     * 标题
     */
    title: String,
    clickClose: Boolean,
  },
};
</script>